<template>
  <div id="app">
    <!-- 通过@/router查看子路由对应的组件 -->
    <router-view></router-view>
  </div>
</template>

<script>

import {
  getBasicByCode,
} from './config/api/api';
export default {
  name: 'app',
  data() {
    return {};
  },
  created() {
    window.HWH5.addEventListener({
      type: 'back',
      func: () => {
        // 监听页面返回事件，return true直接返回，return false，拒绝返回。只支持安卓
        const flag = true;
        return flag;
      }
    }).catch(error => {
      console.log('监听事件发生异常', error);
    });
    // this.getCode()
  },

  methods: {
    async getCode() {
      try {
        HWH5.showLoading();
        const userInfo = await HWH5.getAuthCode();
        console.log('code', userInfo.code);
        //  将免登码传进去作为获取用户信息的参数
        this.getUserInfo(userInfo.code);
        HWH5.hideLoading();
      } catch (error) {
        console.log(error);
      }
    },
    //通过免登码获取用户信息
    getUserInfo(code) {
      let data = {
        code
      };
      HWH5.showLoading();
      getBasicByCode(data)
        .then(res => {
          HWH5.hideLoading();
          this.$store.commit('SAVE_USERINFO', res);
          HWH5.setStorage({
            key: 'userInfo',
            data: res
          }).catch(error => {
            console.log('设置缓存异常', error);
          });
        })
        .catch(error => {
          console.error(error);
        });
    }
  }
};
</script>
<style >
.page {
  background: #f4f8f9;
}
image {
  -ms-interpolation-mode: bicubic;
  -webkit-box-sizing: border-box;
  box-sizing: border-box;
  vertical-align: top;
  border: 0;
  display: block;
  /*禁止用户拷贝或存储图像*/
  -webkit-touch-callout: none;
  background-repeat: no-repeat;
  background-size: 100% 100%;
}
hr {
  display: block;
  padding: 0;
  border: 0;
  height: 0;
  border-top: 1px solid #eeeeee;
  /*线的颜色可以自己进行更改*/
  -webkit-box-sizing: content-box;
  box-sizing: content-box;
}

/*文本-省略号 截断*/

.hz-ellipsis {
  word-wrap: normal;
  /* for IE */
  -webkit-text-overflow: ellipsis;
  -moz-text-overflow: ellipsis;
  -o-text-overflow: ellipsis;
  text-overflow: ellipsis;
  white-space: nowrap;
  overflow: hidden;
}

/*多行位置截断*/

.hz-line-clamp {
  overflow: hidden;
  -webkit-text-overflow: ellipsis;
  -moz-text-overflow: ellipsis;
  -o-text-overflow: ellipsis;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  /*行数*/
  -webkit-box-orient: vertical;
}

/*文本框提示文本颜色设置 - 可根据项目进行局部设置*/

/* WebKit browsers */

::-webkit-input-placeholder {
  color: #ababab;
}

/* Mozilla Firefox 4 to 18 */

:-moz-placeholder {
  color: #ababab;
  opacity: 1;
}

/* Mozilla Firefox 19+ */

::-moz-placeholder {
  color: #ababab;
  opacity: 1;
}

/* Internet Explorer 10+ */

:-ms-input-placeholder {
  color: #ababab;
}

.w {
  width: 100%;
}

.w-20 {
  width: 20%;
}

.w-25 {
  width: 25%;
}
.mt24 {
  margin-top: 24px;
}
.mt12 {
  margin-top: 12px;
}
.mt32 {
  margin-top: 32px;
}
.text-left {
  text-align: left;
}

.text-right {
  text-align: right;
}

.none {
  display: none;
}

.block {
  display: block;
}

.flex {
  display: flex;
}
.flex-center {
  display: flex;
  align-items: center;
  justify-content: center;
}
.flex-left {
  display: flex;
  align-items: center;
}
.flex-right {
  display: flex;
  align-items: center;
  flex-direction: row-reverse;
}
.flex-auto {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.flex-around {
  display: flex;
  justify-content: space-around;
  align-items: center;
}
.flex-column {
  display: flex;
  flex-direction: column;
}
.flex-wrap {
  display: flex;
  flex-wrap: wrap;
}
.flex-stretch {
  display: flex;
  align-items: stretch;
}
.flex0 {
  flex: 0 0 auto;
}

.page-fixed {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  right: 0;
  z-index: 1;
}

.text-overflow {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
</style>



